<!doctype html>
<html>

<head>
    <meta charset="utf-8" />
    <title>WebAssembly Demo - C</title>
    <style type="text/css">
        div {
            font-size: 30px;
            text-align: center;
            color: orange;
        }
    </style>
</head>

<body>
    <div id="textcontent"></div>
    <script type="text/javascript">
        var result;
        fetch("./Sum.wasm")
            .then(bytes => bytes.arrayBuffer())
            .then(mod => WebAssembly.compile(mod))
            .then(module => { return new WebAssembly.Instance(module) })
            .then(instance => {
                console.log(instance);
                result = instance.exports.Sum(1, 2); // 调用C中导入的Sum方法
				console.log("The result of Sum(1, 2) = " + result);
                document.getElementById("textcontent")
                    .innerHTML = "The result of Sum(1, 2) = " + result;
            });
    </script>
</body>

</html>